<template>
	<view class="body">
		<form @submit="formSubmit">
		<view class="face-wapper">
			<image src="../../static/icos/default-face.png" class="face"></image>
		</view>
		
		<view class="info-wapper">
			<label class="words-lbl">账号</label>
		<input name="username" type="text" class="input" value="" placeholder="用户名" placeholder-class="graywords" />
		</view>
		
		<view class="info-wapper" style="margin-top: 40upx;">
			<label class="words-lbl">密码</label>
			<input name="password" type="text" class="input" password="true" placeholder="请输入密码" placeholder-class="graywords" value="" />
		</view>
		
		<button type="warn" form-type="submit" style="margin-top: 60upx;width: 90%;">
			注册/登录
		</button>
		</form>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
			}
		},
		methods: {
			formSubmit(e) {
				var me = this;
				// debugger;
				var username = e.detail.value.username;
				var password = e.detail.value.password;
				// console.log(username);\
				
				// 发起注册请求
				var serverUrl = me.serverUrl;
				uni.request({
					url: serverUrl + '/userLogin',
					method: 'POST',
					data: {
						"username" : username,
						"password": password
					},
					success: res => {
						debugger;
						var userInfo = res.data.data.userInfo;
						uni.setStorageSync("globalUser",userInfo);
						// console.log(userInfo);
						uni.switchTab({
							url: "../me/me"
						});
						
						
					},
					fail: () => {},
					complete: () => {}
				});
				
				
			},
		}
	}
</script>

<style>
	@import url("registLogin.css");
</style>
